<template>
	<view>
		<view class="u-flex u-flex-y-center u-flex-around user-box u-p-l-30 u-p-r-20 u-p-b-30" v-if="isLogin">
			<view class="u-m-r-10">
				<up-avatar :src="user.avatar" size="140"></up-avatar>
			</view>
			<view class="u-flex-1">
				<view class="u-font-18 u-p-b-20">{{ user.username }}</view>
				<view class="u-font-14 u-tips-color">个人简介：test</view>
			</view>
			<view class="u-m-l-10 u-p-10">
				<up-icon name="scan" color="#969799" size="28"></up-icon>
			</view>
			<view class="u-m-l-10 u-p-10">
				<up-icon name="arrow-right" color="#969799" size="28"></up-icon>
			</view>
		</view>
		
		<view class="u-flex u-flex-y-center u-flex-around user-box u-p-l-30 u-p-r-20 u-p-b-30" v-else @click="toLogin">
			<view class="u-m-r-10">
				<up-avatar :src="pic" size="140"></up-avatar>
			</view>
			<view class="u-flex-1">
				<view class="u-font-18 u-p-b-20">未登录，请先登录</view>
			</view>
			<view class="u-m-l-10 u-p-10">
			</view>
			<view class="u-m-l-10 u-p-10">
			</view>
		</view>
		
		<view class="u-m-t-20" v-if="isLogin">
			<up-cell-group>
				<up-cell icon="rmb-circle" title="支付"></up-cell>
			</up-cell-group>
		</view>
		
		<view class="u-m-t-20" v-if="isLogin">
			<up-cell-group>
				<up-cell icon="star" title="收藏"></up-cell>
				<up-cell icon="photo" title="相册"></up-cell>
				<up-cell icon="coupon" title="卡券"></up-cell>
				<up-cell icon="heart" title="关注"></up-cell>
			</up-cell-group>
		</view>
		
		<view class="u-m-t-20" v-if="isLogin">
			<up-cell-group>
				<up-cell icon="setting" title="设置"></up-cell>
			</up-cell-group>
		</view>
	</view>
	
	<up-tabbar
		:value="value99"
		@change="change99"
		:fixed="true"
		:placeholder="true"
		:safeAreaInsetBottom="true"
		activeColor="#6bc493"
	>
		<up-tabbar-item text="首页" icon="home" @click="toIndex" ></up-tabbar-item>
		<up-tabbar-item text="我的" icon="account"></up-tabbar-item>
	</up-tabbar>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { useUserStore } from '@/stores/user.js'

let isLogin = ref(false)
const user = ref({})
const currUser = useUserStore()

onMounted(() => {
	console.log("token:", currUser.token)
	if (currUser.token != '' && currUser.token != undefined) {
		isLogin.value = true
		user.value.username = currUser.username
	}
})
const toLogin = () => {
	console.log("跳转至登录界面")
	uni.navigateTo({
		url: '/pages/login/index'
	});
}

// 底部导航栏99
const value99 = ref(1)
const toIndex = () => {
	console.log("跳转至主页")
	uni.navigateTo({
		url: '/pages/index/index'
	});
}

</script>

<style lang="scss">
page{
	background-color: #ededed;
}

.camera{
	width: 54px;
	height: 44px;
	
	&:active{
		background-color: #ededed;
	}
}
.user-box{
	background-color: #fff;
}
.u-cell-group {
	background-color: #fff;
}
</style>